"""
② 查询所有查询编号小于4或没被删除的学生
"""
import pymysql
from pymysql.cursors import DictCursor

conn = pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    password='6666',
    database='homework'
)
try:
    cursor=conn.cursor(DictCursor)
    sql = """
        select * from student
    """
    ret_num = cursor.execute(sql)
    result = cursor.fetchall()
    print(result)

    for stu in result:
        # 我没有找到“状态”对应的是哪一个键:(
        if stu['DepartmentID']<4 or stu['DepartmentID']==1:
            print(stu['Name'])

except:
    conn.rollback()
